Skip to content

Set up Google Single Sign-On (SSO) in the CoreX backend#39

Merged
Alexandrbig1 merged 7 commits into
OpenCodeChicago:mainfrom
dikamjit-borah:main
Oct 11, 2025
Merged

Set up Google Single Sign-On (SSO) in the CoreX backend#39
Alexandrbig1 merged 7 commits into
OpenCodeChicago:mainfrom
dikamjit-borah:main

Conversation

@dikamjit-borah
Copy link
Copy Markdown
Contributor

Description
Set up Google Single Sign-On (SSO) in the CoreX backend to allow users to register/login with their Google account.
Implements Google OAuth 2.0 using Passport.
Adds endpoints:
GET /auth/google – redirects to Google for login
GET /auth/google/callback – handles Google’s response
Flow:
Verifies Google profile (id, email, name)
If user exists → returns JWT
If new user → creates user in MongoDB with authProvider: 'google', then returns JWT
Secure env vars:
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
GOOGLE_CALLBACK_URL
Documents setup and usage in README.md, including API details for frontend.
Closes: #
Type of Change
[x] New feature
[x] Documentation update
[ ] Bug fix
[ ] Refactor
[ ] Other (please describe):
Acceptance Criteria
[x] User can authenticate with Google and receive a JWT
[x] New Google users are automatically saved in DB
[x] Errors (invalid token, failure to fetch user) are handled
[x] API is documented for frontend use
Checklist
[ ] My code follows the style guidelines of this project
[ ] I have performed a self-review of my code
[ ] I have commented my code where necessary
[x] I have updated documentation (README, Usage, etc.)
[ ] My changes generate no new warnings or errors
[ ] I have added tests (if applicable)
[ ] All tests pass locally with my changes
How to Test
Set env vars: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_CALLBACK_URL.
Start the server and ensure MongoDB is running.
Hit GET /auth/google, complete Google login, verify redirect.
Confirm
Existing Google user receives a valid JWT.
New Google user is created in MongoDB with authProvider: 'google' and receives a JWT.
Error paths return appropriate status and messages for invalid tokens or profile fetch failures.

@dikamjit-borah dikamjit-borah marked this pull request as draft October 10, 2025 15:39
Copy link
Copy Markdown
Contributor

@Alexandrbig1 Alexandrbig1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dikamjit-borah, please delete package.json file from your PR. I installed all packages that you need.

@dikamjit-borah dikamjit-borah marked this pull request as ready for review October 11, 2025 04:43
@dikamjit-borah
Copy link
Copy Markdown
Contributor Author

@Alexandrbig1 Please review and suggest changes if required. You will need to setup the following env variables locally.clientID: GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET,
GOOGLE_CALLBACK_URL
JWT_SECRET

Copy link
Copy Markdown
Contributor

@Alexandrbig1 Alexandrbig1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Open Code Chicago! 🎉
Thank you for making your first contribution here — we’re glad to have you. Approved. Great work!

@Alexandrbig1 Alexandrbig1 merged commit 0138f26 into OpenCodeChicago:main Oct 11, 2025
1 check passed
@Alexandrbig1 Alexandrbig1 added backend Issues related to backend hacktoberfest Special issue for Hacktoberfest hacktoberfest-2025 Special issue for Hacktoberfest 2025 hacktoberfest-accepted This label indicates that a contribution has been accepted and counts toward Hacktoberfest rewards. mongodb MongoDB & database management node.js Backend JavaScript / runtime (Express, APIs, server work) labels Oct 11, 2025
@Alexandrbig1 Alexandrbig1 added this to the Hacktoberfest 2025 milestone Oct 11, 2025
@Alexandrbig1 Alexandrbig1 linked an issue Oct 11, 2025 that may be closed by this pull request
@Alexandrbig1 Alexandrbig1 added the auth Authentication & authorization label Oct 11, 2025
@Alexandrbig1
Copy link
Copy Markdown
Contributor

@dikamjit-borah, congratulations on your merged PR! 🎉 Don’t forget to add yourself as a contributor using our all-contributors bot. You can find instructions in our CONTRIBUTING.md. Thanks again for your contribution!

@dikamjit-borah
Copy link
Copy Markdown
Contributor Author

@all-contributors please add @dikamjit-borah for code

@allcontributors
Copy link
Copy Markdown
Contributor

@dikamjit-borah

I've put up a pull request to add @dikamjit-borah! 🎉

@Alexandrbig1
Copy link
Copy Markdown
Contributor

Hey @dikamjit-borah ,

🎉 Congratulations — your pull request has been merged!
Thank you for your contribution to the CoreX Project as part of Open Code Chicago during Hacktoberfest 2025

You’ve officially earned the Open Code Chicago × CoreX Contributor 2025 badge on Holopin 🏅
👉 Claim your badge here: Claim Badge

Once claimed, you can proudly display it on your GitHub profile, Holopin board, or share it on LinkedIn to celebrate your achievement!

Keep contributing, learning, and building with us 🚀
— Open Code Chicago Team

@Alexandrbig1
Copy link
Copy Markdown
Contributor

Hey @dikamjit-borah ,

🎉 Congratulations on your first merged pull request!
You’ve just taken a huge step in your open-source journey — and we’re so excited it happened here at Open Code Chicago × CoreX 💪

To celebrate this milestone, you’ve earned the “First PR Merged” badge on Holopin 🏅
👉 Claim your badge here: Claim Badge

Once claimed, you can proudly showcase it on your GitHub profile, Holopin board, or share it on LinkedIn to mark your first contribution to the open-source world 🌟

Keep contributing, keep growing, and welcome to the Open Code Chicago community! 🚀
— Open Code Chicago Team

@Alexandrbig1 Alexandrbig1 added the badge-awarded Added when a contributor has received a Holopin badge label Oct 29, 2025
@Alexandrbig1
Copy link
Copy Markdown
Contributor

Hey @dikamjit-borah ,

🔥 Congratulations — your backend contributions have been outstanding!
Your work on the CoreX Project has strengthened our foundation, improved functionality, and helped bring our open source vision to life during Hacktoberfest 2025.

You’ve officially earned the Backend Engineer 2025 badge from Open Code Chicago × CoreX 🏅
👉 Claim your badge here: Claim Badge

Thank you for writing clean, secure, and efficient code that powers our project behind the scenes.
Your expertise keeps everything running smoothly 🚀

— The Open Code Chicago Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Authentication & authorization backend Issues related to backend badge-awarded Added when a contributor has received a Holopin badge hacktoberfest Special issue for Hacktoberfest hacktoberfest-2025 Special issue for Hacktoberfest 2025 hacktoberfest-accepted This label indicates that a contribution has been accepted and counts toward Hacktoberfest rewards. mongodb MongoDB & database management node.js Backend JavaScript / runtime (Express, APIs, server work)

Development

Successfully merging this pull request may close these issues.

Implement Google SSO (OAuth2) – Backend

2 participants